package net.hn.hnms.biz.plan.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import net.hn.hnms.biz.plan.request.DimMiningFaceReq;
import net.hn.hnms.biz.plan.request.PlanPriorityWorkReq;
import net.hn.hnms.biz.plan.service.PlanPriorityWorkService;
import net.hn.hnms.biz.plan.vo.PlanPriorityWorkVo;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.core.domain.ResponsePage;
import net.hn.hnms.sys.common.core.web.controller.BaseController;
import net.hn.hnms.sys.common.log.annotation.Log;
import net.hn.hnms.sys.common.log.enums.BusinessType;
import net.hn.hnms.sys.common.mybatis.core.page.PageQuery;
import net.hn.hnms.sys.common.satoken.config.AutoSetMineCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "重点工作计划模块", tags = {"重点计划"})
@RestController
@RequestMapping("/PriorityWork")
public class PlanPriorityWorkController   extends BaseController {


    @Autowired
    private PlanPriorityWorkService planPriorityWorkService;


    /**
     * 新增重点工作计划
     */
    @ApiOperation("新增重点工作计划")
    @SaCheckPermission("plan:PlanTunnelRepair:add")
    @PostMapping("/add")
    @Log(title = "新增重点工作计划", businessType = BusinessType.INSERT)
    public R<Void> add(@Validated @RequestBody PlanPriorityWorkReq planMining) {
        return toAjax(planPriorityWorkService.insert(planMining));
    }
    /**
     * 删除重点工作计划
     */
    @ApiOperation("删除重点工作计划")
    @SaCheckPermission("plan:PlanTunnelRepair:delete")
    @ApiImplicitParam(name = "idList", value = "要删除的id值,用逗号间隔", required = true, allowMultiple = true, dataType = "String", paramType = "query")
    @DeleteMapping("delete")
    @Log(title = "删除重点工作计划", businessType = BusinessType.DELETE)
    public R<Void> delete(@RequestParam("idList") List<String> idList) {
        planPriorityWorkService.deleteBatch(idList);
        return R.ok();
    }


    /**
     * 修改重点工作计划
     */
    @ApiOperation("修改重点工作计划")
    @SaCheckPermission("plan:PlanTunnelRepair:update")
    @PutMapping("/update")
    @Log(title = "修改重点工作计划", businessType = BusinessType.UPDATE)
    public R<Void> update(@Validated @RequestBody PlanPriorityWorkReq planMining) {
        planPriorityWorkService.updateById(planMining);
        return R.ok();
    }


    /**
     * 启用/禁用
     */
    @ApiOperation("启用/禁用")
    @SaCheckPermission("plan:PlanTunnelRepair:status:change")
    @PutMapping("/status/change/{id}/{status}")
    @Log(title = "重点工作计划启用/禁用", businessType = BusinessType.GRANT)
    public R<Void> changeStatus(@PathVariable("id") String id, @PathVariable("status") Integer status) {
        planPriorityWorkService.changeStatus(id, status);
        return R.ok();
    }

    /**
     * 获取重点工作计划列表
     */
    @ApiOperation("获取重点工作计划分页列表")
//    @SaCheckPermission("plan:PlanTunnelRepair:page")
    @GetMapping("/page")
    @AutoSetMineCode
    public R<ResponsePage<PlanPriorityWorkVo>> page(PlanPriorityWorkReq planMining, PageQuery pageQuery) {
        return R.ok(planPriorityWorkService.selectPageList(planMining, pageQuery));
    }


    /**
     * 获取重点工作计划列表
     */
    @ApiOperation("获取重点工作计划列表")
//    @SaCheckPermission("plan:PlanTunnelRepair:list")
    @GetMapping("/list")
    public R<List<PlanPriorityWorkVo>> list(PlanPriorityWorkReq planMining) {
        return R.ok(planPriorityWorkService.selectList(planMining));
    }

    /**
     * 获取重点工作计划详情
     */
    @ApiOperation("获取重点工作计划详情")
//    @SaCheckPermission("plan:PlanTunnelRepair:detail")
    @GetMapping("/{id}")
    public R<PlanPriorityWorkVo> detail(@PathVariable("id") String id) {
        return R.ok(planPriorityWorkService.selectDetailById(id));
    }
}
